<template>
	<view>
		<view class="mine">
			<view v-if="showOut" class="clearSync" @tap="out()">退出登录</view>
			<view v-else class="login" @tap="dotoLogin()">登录</view>
			<view>
				<image :src=imgUrl class="userImg"></image>
			</view>
			<view class="userName">
				{{userName}}
			</view>
		</view>
		<view class="tips" @tap="gotoHelp()">我想提个建议</view>
		<view class="">
			<!-- 工具1 -->
			<!-- <view  class="tips" @tap="gotoEachHelp()">互助答疑</view> -->
			<view class="otherToos">其他学习工具</view>
			<view class="tools">更新中</view>
			</view>
		
		<view class="">
			<!-- 漂浮广告 -->
			</view>

		<template>
					<view>
						<uni-popup ref="showDialog" type="dialog">
							<uni-popup-dialog ref="inputClose"  mode="base" title="确定退出登录？"
								 @confirm="dialogInputConfirm"></uni-popup-dialog>
						</uni-popup>
					</view>
		</template>
	</view>
</template>

<script>
	import{getInfo} from '../../api/login.js'
  export default {
    data() {
      return {
		  imgUrl: '',
		  userName:'',
		  showOut: false,
      }
    },
	mounted() {
		//this.imgUrl = 'https://pcsdata.baidu.com/thumbnail/9fbbc9142m715363c4df72d16e34b6f1?fid=3725398796-16051585-409604223623721&rt=pr&sign=FDTAER-yUdy3dSFZ0SVxtzShv1zcMqd-i9sStVM6hMkOMh7Lf67w8KbTGJw%3D&expires=2h&chkv=0&chkbd=0&chkpc=&dp-logid=194611098787787982&dp-callid=0&time=1667458800&bus_no=26&size=c1600_u1600&quality=100&vuk=-&ft=video'
		this.userName = uni.getStorageSync("nickName")
		this.imgUrl = uni.getStorageSync("avaterUrl")
		if(this.imgUrl){
			this.showOut = true
		}
		
	},
    methods: {
		out(){
			this.$refs.showDialog.open()
		},
		dotoLogin(){
			uni.navigateTo({
				url:'/pages/login'
			})
		},
		gotoEachHelp(){
			uni.navigateTo({
				url:'/pages/help/eachelp'
			})
		},
		dialogInputConfirm(val) {
			uni.navigateTo({
				title: '正在注销登录'
			})
			setTimeout(() => {
				uni.hideLoading()
				uni.clearStorage()
				// 关闭窗口后，恢复默认内容
				uni.reLaunch({
					url:'/pages/mine/index'
				})
			}, 1000)
		},
		gotoHelp(){
			uni.navigateTo({
				url:'/pages/help/help'
			})
		},
    }
  }
</script>

<style lang="scss">
 .mine{
	 background-color: cadetblue;
	 margin: 10rpx;
	 border-radius: 5px;
 }
 .login{
	 color: white;
	 text-align: center;
 }
 .clearSync{
	 color: lightcyan;
	 float: right;
 }
 .userImg{
	 height: 100rpx;
	 width: 100rpx;
	 margin-top: 100rpx;
	 margin-left: 310rpx;
	 border-radius: 50px;
	 border: 1px solid lightslategrey;
 }
 .userName{
	 margin-left: 320rpx;
	 margin-top: 20rpx;
	 padding-bottom: 50rpx;
	 color: lightcyan;
 }
 .tips{
	 margin: 10rpx;
	 padding: 10rpx;
	 text-align: center;
	 font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
	 border: 1px solid lightblue;
 }
 .tipsimg{
	 height: 30rpx;
	 width: 30rpx;
	 margin-right: 10rpx;
 }
 .otherToos {
	 text-align: center;
 }
 .tools{
	 margin: 10rpx;
 }
</style>
